﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Windows;

namespace QLKS.ViewModels
{
    static public class KhachHangViewModel
    {
        static public DataTable GetAllKhachHang(string columns)
        {
            DataTable tb = new DataTable();
            tb = Models.KhachHangModel.GetAllKhachHang(columns);
            return tb;
        }

        //Tạo mới khách hàng
        static public DataTable CreateNewKhachHang()
        {
            DataTable tb = new DataTable();
            tb = Models.KhachHangModel.CreateNewKhachHang();
            return tb;
        }

        //Lấy danh sách khách hàng
        static public DataTable GetAllKhachHang()
        {
            DataTable tb = new DataTable();
            tb = Models.KhachHangModel.GetAllKhachHang();
            return tb;
        }

        //Lấy nhóm khách hàng
        static public DataTable GetNhomKhachHang()
        {
            DataTable tb = new DataTable();
            tb = Models.KhachHangModel.GetNhomKhachHang();
            return tb;
        }

        //Lấy mã kh mới
        static public string GetMaKhMoi()
        {
            return Models.KhachHangModel.GetMaKhMoi();
        }

        //thêm Khách hàng
        static public bool ThemKhachHang(DataTable tb)
        {
            try
            {
                Models.KhachHangModel.ThemKhachHang(tb);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "HotelManager", MessageBoxButton.OK, MessageBoxImage.Error);
                if (Models.DataProviderModel.IsOpen)
                    Models.DataProviderModel.Close();
                return false;
            }
            return true;
        }

        //Xóa khách hàng
        static public bool XoaKhachHang(string ma)
        {
            try
            {
                Models.KhachHangModel.XoaKhachHang(ma);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "HotelManager", MessageBoxButton.OK, MessageBoxImage.Error);
                if (Models.DataProviderModel.IsOpen)
                    Models.DataProviderModel.Close();
                return false;
            }
            return true;
        }
    }
}
